﻿' _______                 _      _        _____               _       
'|__   __|               | |    | |      |  __ \             | |      
'   | | _   _  _ __ ___  | |__  | |  ___ | |  | |  ___   ___ | | __   
'   | || | | || '_ ` _ \ | '_ \ | | / _ \| |  | | / _ \ / __|| |/ /   
'   | || |_| || | | | | || |_) || ||  __/| |__| ||  __/| (__ |   <  _ 
'   |_| \__,_||_| |_| |_||_.__/ |_| \___||_____/  \___| \___||_|\_\(_)
Imports System.Collections.Generic
Imports System.Text
Imports System.Web
Imports System.Net
Imports System.IO

'TumblePower based on WinTumblr
'***Note*** - Please, do not modify TumblePower(only modify it if you want to ADD functions, and modify only your code)

Public Class Status
    Private iCode As Integer = 0
    Private sMsg As String = ""

    Public Property Code() As Integer
        Get
            Return iCode
        End Get
        Set(ByVal value As Integer)
            iCode = value
        End Set
    End Property
    Public Property Msg() As String
        Get
            Return sMsg
        End Get
        Set(ByVal value As String)
            sMsg = value
        End Set
    End Property

    Public Enum KnownCodes As Integer
        Ok = 200
        Created = 201
    End Enum
End Class

Public Class TumblrEventArgs
    Inherits EventArgs
    Public Sub New(ByVal status As Status)
        Me.message = status.Msg
    End Sub
    Public message As String
End Class

Public Class tumblr
    Public NotInheritable Class Proxy
        Private Sub New()
        End Sub
        Private Shared bUse As System.Nullable(Of Boolean) = False
        Private Shared sUser As String = ""
        Private Shared sPwd As String = ""
        Private Shared sUrl As String = ""
        Private Shared sPort As String = ""
        Private Shared sDomain As String = ""
        Public Shared Property UseProxy() As System.Nullable(Of Boolean)
            Get
                Return bUse
            End Get
            Set(ByVal value As System.Nullable(Of Boolean))
                bUse = value
            End Set
        End Property
        Public Shared Property UserName() As String
            Get
                Return sUser
            End Get
            Set(ByVal value As String)
                sUser = value
            End Set
        End Property
        Public Shared Property Password() As String
            Get
                Return sPwd
            End Get
            Set(ByVal value As String)
                sPwd = value
            End Set
        End Property
        Public Shared Property ServerURL() As String
            Get
                Return sUrl
            End Get
            Set(ByVal value As String)
                sUrl = value
            End Set
        End Property
        Public Shared Property ServerPort() As String
            Get
                Return sPort
            End Get
            Set(ByVal value As String)
                sPort = value
            End Set
        End Property
        Public Shared Property Domain() As String
            Get
                Return sDomain
            End Get
            Set(ByVal value As String)
                sDomain = value
            End Set
        End Property
    End Class
    ' Lets create classes for each of the message types for
    ' future features that may include offline storage of messages.
    ' This will enable you to enter a bunch of posts and upload them 
    ' when you are connected to the internet (if you implement that 
    ' feature of course).
    Public Class Account
        Private sEmail As String = ""
        Private sPassword As String = ""
        Private sGroup As String = ""
        Private bPrivate As Boolean = False
        Private sDate As String = ""
        Private sTags As String = ""

        Public Property Email() As String
            Get
                Return sEmail
            End Get
            Set(ByVal value As String)
                sEmail = value
            End Set
        End Property
        Public Property Password() As String
            Get
                Return sPassword
            End Get
            Set(ByVal value As String)
                sPassword = value
            End Set
        End Property
        Public Property Group() As String
            Get
                Return sGroup
            End Get
            Set(ByVal value As String)
                sGroup = value
            End Set
        End Property
        Public Property IsPrivate() As Boolean
            Get
                Return bPrivate
            End Get
            Set(ByVal value As Boolean)
                bPrivate = value
            End Set
        End Property
        Public Property DateOfPost() As DateTime
            Get
                Return Convert.ToDateTime(sDate)
            End Get
            Set(ByVal value As DateTime)
                If value > DateTime.Now Then
                    sDate = ""
                Else
                    sDate = value.ToString("yyyy-MM-dd HH:mm:ss")
                End If
            End Set
        End Property
        Public Property StrDateOfPost() As String
            Get
                Return sDate
            End Get
            Set(ByVal value As String)
                sDate = value
            End Set
        End Property
        Public Property Tags() As String
            Get
                Return sTags
            End Get
            Set(ByVal value As String)
                sTags = value
            End Set
        End Property
    End Class
    Public Class Text
        Inherits Account
        Private sTitle As String = ""
        Private sBody As String = ""
        Public Property Title() As String
            Get
                Return sTitle
            End Get
            Set(ByVal value As String)
                sTitle = System.Web.HttpUtility.UrlEncode(value, Encoding.UTF8)
            End Set
        End Property
        Public Property Body() As String
            Get
                Return sBody
            End Get
            Set(ByVal value As String)
                Dim s As String = value.Replace(vbCr, "")
                s = s.Replace(vbLf, "")
                sBody = System.Web.HttpUtility.UrlEncode(s, Encoding.UTF8)
            End Set
        End Property
    End Class

    Public Class Photo
        Inherits Account
        ' This class will convert a file into a URL-encoded string
        ' and store the string in sData. I thought of doing it in the  
        ' btnPost_Click event, however I felt it would be a better 
        ' design decision to have it as part of the Photo object.
        Private sSource As String = ""
        Private sData As String = ""
        Private sCaption As String = ""
        Private sClickThroughUrl As String = ""
        Public Property Source() As String
            Get
                Return sSource
            End Get
            Set(ByVal value As String)
                sSource = value
            End Set
        End Property
        Public Property Data() As String
            Get
                Return sData
            End Get
            ' Check whether the file exists and stream it-->url-encode it
            Set(ByVal value As String)
                If value.Length > 0 Then
                    If System.IO.File.Exists(value) Then
                        Try
                            Dim whole As Byte() = System.IO.File.ReadAllBytes(value)
                            sData = System.Web.HttpUtility.UrlEncode(whole)
                        Catch e As Exception
                            ' Let the user know what went wrong.
                            Throw e
                        End Try
                    Else

                        Throw New Exception("There was something wrong with the File you selected. Please verify that the file exists.")
                    End If
                End If
            End Set
        End Property
        Public Property Caption() As String
            Get
                Return sCaption
            End Get
            Set(ByVal value As String)
                Dim s As String = value.Replace(vbCr, "")
                s = s.Replace(vbLf, "")
                sCaption = System.Web.HttpUtility.UrlEncode(s, Encoding.UTF8)
            End Set
        End Property
        Public Property ClickThroughUrl() As String
            Get
                Return sClickThroughUrl
            End Get
            Set(ByVal value As String)
                sClickThroughUrl = value
            End Set
        End Property
    End Class

    Public Class Quote
        Inherits Account
        Private sQuote As String = ""
        Private sSource As String = ""
        Public Property TheQuote() As String
            Get
                Return sQuote
            End Get
            Set(ByVal value As String)
                sQuote = System.Web.HttpUtility.UrlEncode(value, Encoding.UTF8)
            End Set
        End Property
        Public Property Source() As String
            Get
                Return sSource
            End Get
            Set(ByVal value As String)
                Dim s As String = value.Replace(vbCr, "")
                s = s.Replace(vbLf, "")
                sSource = System.Web.HttpUtility.UrlEncode(s, Encoding.UTF8)
            End Set
        End Property
    End Class

    Public Class Link
        Inherits Account
        Private sName As String = ""
        Private sUrl As String = ""
        Private sDescription As String = ""
        Public Property Name() As String
            Get
                Return sName
            End Get
            Set(ByVal value As String)
                sName = System.Web.HttpUtility.UrlEncode(value, Encoding.UTF8)
            End Set
        End Property
        Public Property Url() As String
            Get
                Return sUrl
            End Get
            Set(ByVal value As String)
                sUrl = value
            End Set
        End Property
        Public Property Description() As String
            Get
                Return sDescription
            End Get
            Set(ByVal value As String)
                Dim s As String = value.Replace(vbCr, "")
                s = s.Replace(vbLf, "")
                sDescription = System.Web.HttpUtility.UrlEncode(s, Encoding.UTF8)
            End Set
        End Property
    End Class

    Public Class Chat
        Inherits Account
        Private sTitle As String = ""
        Private sChat As String = ""
        Public Property Title() As String
            Get
                Return sTitle
            End Get
            Set(ByVal value As String)
                sTitle = System.Web.HttpUtility.UrlEncode(value, Encoding.UTF8)
            End Set
        End Property
        Public Property TheChat() As String
            Get
                Return sChat
            End Get
            Set(ByVal value As String)
                sChat = System.Web.HttpUtility.UrlEncode(value, Encoding.UTF8)
            End Set
        End Property
    End Class

    Public Class Video
        Inherits Account
        Private sEmbed As String = ""
        Private sCaption As String = ""
        Public Property Embed() As String
            Get
                Return sEmbed
            End Get
            Set(ByVal value As String)
                sEmbed = value
            End Set
        End Property
        Public Property Caption() As String
            Get
                Return sCaption
            End Get
            Set(ByVal value As String)
                Dim s As String = value.Replace(vbCr, "")
                s = s.Replace(vbLf, "")
                sCaption = System.Web.HttpUtility.UrlEncode(s, Encoding.UTF8)
            End Set
        End Property
    End Class

    Public Class Audio
        Inherits Account
        Private sExternallyHostedUrl As String = ""
        Private sCaption As String = ""
        Public Property ExternallyHostedUrl() As String
            Get
                Return sExternallyHostedUrl
            End Get
            Set(ByVal value As String)
                sExternallyHostedUrl = value
            End Set
        End Property
        Public Property Caption() As String
            Get
                Return sCaption
            End Get
            Set(ByVal value As String)
                Dim s As String = value.Replace(vbCr, "")
                s = s.Replace(vbLf, "")
                sCaption = System.Web.HttpUtility.UrlEncode(s, Encoding.UTF8)
            End Set
        End Property
    End Class

    Public Delegate Sub TumblrEventHandler(ByVal sender As Object, ByVal te As TumblrEventArgs)
    Public Event TumblrEvent As TumblrEventHandler
    Public Sub ActivateTumblrEvent(ByVal status As Status)
        Dim TumblrArgs As New TumblrEventArgs(status)
        RaiseEvent TumblrEvent(Me, TumblrArgs)
    End Sub

    ' This is important!
    ' The only rule when using this source so that derivative works can be identified
    ' You MUST append/prepend/include within the generator tag the phrase:
    ' "WinTumblr" or "with WinTumblr" or "WinTumblr modified by" or "based on WinTumblr"
    Private generator As String = "TumbleDeck/TumblePower based on WinTumblr http://tumbledeck.codeplex.com/"

    Private Function PostIt(ByVal data As Byte()) As Status
        ' Generic Post to Tumblr method            
        Dim myRequest As HttpWebRequest
        Dim response As HttpWebResponse = Nothing
        Dim newStream As Stream = Nothing
        Dim status As New Status()
        ' Prepare web request...
        myRequest = DirectCast(WebRequest.Create("http://www.tumblr.com/api/write"), HttpWebRequest)
        'myRequest.Proxy            
        Dim myProxy As WebProxy
        Dim newUri As Uri
        If (Proxy.UseProxy IsNot Nothing) AndAlso CBool(Proxy.UseProxy) Then
            Try
                myProxy = New WebProxy()
                newUri = New Uri(Proxy.ServerURL & ":" & Proxy.ServerPort)
                myProxy.Address = newUri
                If (Proxy.Domain IsNot Nothing) AndAlso (Proxy.Domain.Length > 0) Then
                    myProxy.Credentials = New NetworkCredential(Proxy.UserName, Proxy.Password, Proxy.Domain)
                Else
                    myProxy.Credentials = New NetworkCredential(Proxy.UserName, Proxy.Password)
                End If
                myRequest.Proxy = myProxy
            Catch ex As Exception
                status.Msg = Convert.ToString(ex.Message)
            End Try
        End If
        myRequest.Credentials = CredentialCache.DefaultCredentials
        myRequest.Method = "POST"
        myRequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
        myRequest.ReadWriteTimeout = 600000
        ' Ten minutes - default should be 5 minutes. Change made due to timeout on larger uploads
        myRequest.Timeout = 600000
        'header("Content-Type: text/html; charset=iso-8859-1");            
        myRequest.ContentLength = data.Length
        Try
            newStream = myRequest.GetRequestStream()
            ' Send the data.
            newStream.WriteTimeout = 600000
            ' Ten minutes - Change made due to timeout on larger uploads. I wonder which is enforced? myRequest or the newStream.
            newStream.Write(data, 0, data.Length)
            ' Get the response
            response = DirectCast(myRequest.GetResponse(), HttpWebResponse)
            status.Code = Convert.ToInt32(response.StatusCode)
            status.Msg = response.StatusDescription
        Catch ex As ProtocolViolationException
            status.Msg = Convert.ToString(ex.Message)
        Catch ex As NotSupportedException
            status.Msg = Convert.ToString(ex.Message)
        Catch ex As WebException
            status.Msg = Convert.ToString(ex.Message)
        Catch e As Exception
            status.Msg = Convert.ToString(e.Message)
        Finally
            If response IsNot Nothing Then
                response.Close()
            End If
            If newStream IsNot Nothing Then
                newStream.Close()
            End If
            ActivateTumblrEvent(status)
        End Try
        Return status
    End Function

    Public Delegate Function apostText(ByVal text As Text) As Status

    Public Function postText(ByVal text As Text) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & text.Email
        postData += "&password=" & text.Password
        If text.Group.Length > 0 Then
            postData += "&group=" & text.Group
        End If
        postData += "&type=regular"
        If ((text.Title Is Nothing) OrElse (text.Title = "")) AndAlso ((text.Body Is Nothing) OrElse (text.Body = "")) Then
            Throw New ArgumentNullException()
        Else
            If (text.Title IsNot Nothing) AndAlso (text.Title <> "") Then
                postData += "&title=" & text.Title
            End If
            If (text.Body IsNot Nothing) AndAlso (text.Body <> "") Then
                postData += "&body=" & text.Body
            End If
        End If
        postData += "&generator=" & generator
        If text.StrDateOfPost.Length > 0 Then
            postData += "&date=" & text.StrDateOfPost
        End If
        If text.IsPrivate Then
            postData += "&private=1"
        End If
        If text.Tags.Length > 0 Then
            postData += "&tags=" & text.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function apostPhoto(ByVal photo As Photo) As Status
    Public Function postPhoto(ByVal photo As Photo) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & photo.Email
        postData += "&password=" & photo.Password
        If photo.Group.Length > 0 Then
            postData += "&group=" & photo.Group
        End If
        postData += "&type=photo"
        If ((photo.Source Is Nothing) OrElse (photo.Source = "")) AndAlso ((photo.Data Is Nothing) OrElse (photo.Data = "")) Then
            Throw New ArgumentNullException()
        Else
            If (photo.Source IsNot Nothing) AndAlso (photo.Source <> "") Then
                postData += "&source=" & photo.Source
            Else
                ' Don't bother sending a picture if the source is here
                If (photo.Data IsNot Nothing) AndAlso (photo.Data <> "") Then
                    postData += "&data=" & photo.Data
                End If
            End If
            If (photo.Caption IsNot Nothing) AndAlso (photo.Caption <> "") Then
                postData += "&caption=" & photo.Caption
            End If
            If (photo.ClickThroughUrl IsNot Nothing) AndAlso (photo.ClickThroughUrl <> "") Then
                postData += "&click-through-url=" & photo.ClickThroughUrl
            End If
        End If
        postData += "&generator=" & generator
        If photo.StrDateOfPost.Length > 0 Then
            postData += "&date=" & photo.StrDateOfPost
        End If
        If photo.IsPrivate Then
            postData += "&private=1"
        End If
        If photo.Tags.Length > 0 Then
            postData += "&tags=" & photo.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function apostQuote(ByVal quote As Quote) As Status
    Public Function postQuote(ByVal quote As Quote) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & quote.Email
        postData += "&password=" & quote.Password
        If quote.Group.Length > 0 Then
            postData += "&group=" & quote.Group
        End If
        postData += "&type=quote"
        If (quote.TheQuote Is Nothing) OrElse (quote.TheQuote = "") Then
            Throw New ArgumentNullException()
        Else
            If (quote.TheQuote IsNot Nothing) AndAlso (quote.TheQuote <> "") Then
                postData += "&quote=" & quote.TheQuote
            End If
            If (quote.Source IsNot Nothing) AndAlso (quote.Source <> "") Then
                postData += "&source=" & quote.Source
            End If
        End If
        postData += "&generator=" & generator
        If quote.StrDateOfPost.Length > 0 Then
            postData += "&date=" & quote.StrDateOfPost
        End If
        If quote.IsPrivate Then
            postData += "&private=1"
        End If
        If quote.Tags.Length > 0 Then
            postData += "&tags=" & quote.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function apostLink(ByVal link As Link) As Status
    Public Function postLink(ByVal link As Link) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & link.Email
        postData += "&password=" & link.Password
        If link.Group.Length > 0 Then
            postData += "&group=" & link.Group
        End If
        postData += "&type=link"
        If (link.Url Is Nothing) OrElse (link.Url = "") Then
            Throw New ArgumentNullException()
        Else
            If (link.Name IsNot Nothing) AndAlso (link.Name <> "") Then
                postData += "&name=" & link.Name
            End If
            If (link.Url IsNot Nothing) AndAlso (link.Url <> "") Then
                postData += "&url=" & link.Url
            End If
            If (link.Description IsNot Nothing) AndAlso (link.Description <> "") Then
                postData += "&description=" & link.Description
            End If
        End If
        postData += "&generator=" & generator
        If link.StrDateOfPost.Length > 0 Then
            postData += "&date=" & link.StrDateOfPost
        End If
        If link.IsPrivate Then
            postData += "&private=1"
        End If
        If link.Tags.Length > 0 Then
            postData += "&tags=" & link.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function apostChat(ByVal chat As Chat) As Status
    Public Function postChat(ByVal chat As Chat) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & chat.Email
        postData += "&password=" & chat.Password
        If chat.Group.Length > 0 Then
            postData += "&group=" & chat.Group
        End If
        postData += "&type=conversation"
        If (chat.TheChat Is Nothing) OrElse (chat.TheChat = "") Then
            Throw New ArgumentNullException()
        Else
            If (chat.Title IsNot Nothing) AndAlso (chat.Title <> "") Then
                postData += "&title=" & chat.Title
            End If
            If (chat.TheChat IsNot Nothing) AndAlso (chat.TheChat <> "") Then
                postData += "&conversation=" & chat.TheChat
            End If
        End If
        postData += "&generator=" & generator
        If chat.StrDateOfPost.Length > 0 Then
            postData += "&date=" & chat.StrDateOfPost
        End If
        If chat.IsPrivate Then
            postData += "&private=1"
        End If
        If chat.Tags.Length > 0 Then
            postData += "&tags=" & chat.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function apostVideo(ByVal video As Video) As Status
    Public Function postVideo(ByVal video As Video) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & video.Email
        postData += "&password=" & video.Password
        If video.Group.Length > 0 Then
            postData += "&group=" & video.Group
        End If
        postData += "&type=video"
        If (video.Embed Is Nothing) OrElse (video.Embed = "") Then
            Throw New ArgumentNullException()
        Else
            If (video.Embed IsNot Nothing) AndAlso (video.Embed <> "") Then
                postData += "&embed=" & video.Embed
            End If
            If (video.Caption IsNot Nothing) AndAlso (video.Caption <> "") Then
                postData += "&caption=" & video.Caption
            End If
        End If
        postData += "&generator=" & generator
        If video.StrDateOfPost.Length > 0 Then
            postData += "&date=" & video.StrDateOfPost
        End If
        If video.IsPrivate Then
            postData += "&private=1"
        End If
        If video.Tags.Length > 0 Then
            postData += "&tags=" & video.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function apostAudio(ByVal audio As Audio) As Status
    Public Function postAudio(ByVal audio As Audio) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & audio.Email
        postData += "&password=" & audio.Password
        If audio.Group.Length > 0 Then
            postData += "&group=" & audio.Group
        End If
        postData += "&type=audio"
        If (audio.ExternallyHostedUrl Is Nothing) OrElse (audio.ExternallyHostedUrl = "") Then
            Throw New ArgumentNullException()
        Else
            If (audio.ExternallyHostedUrl IsNot Nothing) AndAlso (audio.ExternallyHostedUrl <> "") Then
                postData += "&externally-hosted-url=" & audio.ExternallyHostedUrl
            End If
            If (audio.Caption IsNot Nothing) AndAlso (audio.Caption <> "") Then
                postData += "&caption=" & audio.Caption
            End If
        End If
        postData += "&generator=" & generator
        If audio.StrDateOfPost.Length > 0 Then
            postData += "&date=" & audio.StrDateOfPost
        End If
        If audio.IsPrivate Then
            postData += "&private=1"
        End If
        If audio.Tags.Length > 0 Then
            postData += "&tags=" & audio.Tags
        End If

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function aAuthenticate(ByVal account As Account) As Status
    Public Function Authenticate(ByVal account As Account) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & account.Email
        postData += "&password=" & account.Password
        postData += "&action=authenticate"
        postData += "&generator=" & generator

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function aCheckVimeo(ByVal account As Account) As Status
    Public Function CheckVimeo(ByVal account As Account) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & account.Email
        postData += "&password=" & account.Password
        postData += "&action=check-vimeo"
        postData += "&generator=" & generator

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function

    Public Delegate Function aCheckAudio(ByVal account As Account) As Status
    Public Function CheckAudio(ByVal account As Account) As Status
        Dim enc As Encoder = Encoding.UTF8.GetEncoder()
        Dim postData As String = "email=" & account.Email
        postData += "&password=" & account.Password
        postData += "&action=check-audio"
        postData += "&generator=" & generator

        Dim chr As Char() = postData.ToCharArray()
        Dim byteCount As Integer = enc.GetByteCount(chr, 0, chr.Length, True)
        Dim data As Byte() = New [Byte](byteCount - 1) {}
        Dim bytesEncodedCount As Integer = enc.GetBytes(chr, 0, chr.Length, data, 0, True)
        Return PostIt(data)
    End Function
End Class

